const request = require('./request')

const BASE_URL = '/finance/account'

/**
 * 账户初始化
 * @returns 
 */
function accountInit() {
  return request.get(BASE_URL + '/init')
}

/**
 * 获取该用户所有的列表
 * @returns 
 */
function getAllAccounts() {
  return request.get(BASE_URL + '/accounts')
}

/**
 * 设置为默认
 * @param {*} accountId 账户id 
 * @returns 
 */
function setDefaultFlag(accountId) {
  return request.post(BASE_URL + '/set/default-flag/'+ accountId)
}

/**
 * 创建账户
 * @param {*} params 
 * @returns 
 */
function accountAdd(params) {
  return request.post(BASE_URL + '/create', params)
}

/**
 * 编辑账户
 * @param {*} params 
 * @returns 
 */
function accountEdit(params) {
  return request.put(BASE_URL + '/edit/'+ params.id, params)
}

/**
 * 删除账户
 * @param {*} accountId 
 * @returns 
 */
function accountDelete(accountId) {
  return request.post(BASE_URL + '/delete/'+ accountId)
}
module.exports = {
  getAllAccounts,
  accountInit,
  setDefaultFlag,
  accountAdd,
  accountEdit,
  accountDelete
} 